home *** CD-ROM | disk | FTP | other *** search
- #include "defs.h"
-
- har *progname;
-
- #ifdef STANDALONE
- ain(argc, argv, envp)
- #else
- onvert_main(argc, argv, envp)
- #endif
- int argc;
- char **argv;
- char **envp;
- {
- register int i, j;
- int width, height;
- int depth, depth_reqd;
- Pixrect *pr;
- int ival;
- int files;
- int minval, maxval;
-
- width = height = 10;
- depth_reqd = 8;
-
- progname = strsave(argv[0]);
- parse_profile(&argc, argv, envp);
-
- while ((gc = getopt(argc, argv, "w:h:d:")) != EOF)
- switch (gc) {
- case 'w':
- width = atoi(optarg);
- break;
- case 'h':
- height = atoi(optarg);
- break;
- case 'd':
- depth_reqd = atoi(optarg);
- break;
- case '?':
- errflag++;
- break;
- }
-
- if (errflag)
- error((char *) 0, "Usage: %s: [-w width] [-h height] [-d depth] [infile] [outfile]\n", progname);
-
- for (stream = 0; optind < argc; stream++, optind++)
- if (stream < 2 && strcmp(argv[optind], "-") != 0)
- if (freopen(argv[optind], mode[stream], f[stream]) == NULL)
- error("%s %s", PR_IO_ERR_INFILE, argv[optind]);
-
- if ((depth = ROUND_DEPTH(depth_reqd)) == NOT_SUPPORTED)
- error(ALV_ERR_DEPTH_NO_SUPPORT);
-
- maxval = MAXLEVEL(depth_reqd);
- minval = 0;
-
- if ((pr = mem_create(width, height, depth)) == NULL)
- error("mem_create returned NULL");
-
- for (j = 0; j < height; j++)
- for (i = 0; i < width; i++) {
- scanf("%d", &ival);
- ival = MAX(minval, ival);
- ival = MIN(maxval, ival);
- pr_put(pr, i, j, ival);
- }
-
- pr_dump(pr, stdout, NULL, RT_STANDARD, 0);
- }
-